<template>
    <div id="rightsManagement">
        <!--搜索框-->
        <div class="salesman-tree">
            <el-button type="primary" class="salesman-tree-save">保存</el-button>
            <el-tree
                :expand-on-click-node="false"
                :props="defaultProps"
                ref="tree"
                :data="data3"
                :default-expand-all="true"
                show-checkbox
                node-key="id">

            </el-tree>
        </div>
        <div class="salesman-content">
            <div class="buttons">
                <el-button @click="getCheckedNodes">通过 node 获取</el-button>
                <el-button @click="getCheckedKeys">通过 key 获取</el-button>
                <el-button @click="setCheckedNodes">通过 node 设置</el-button>
                <el-button @click="setCheckedKeys">通过 key 设置</el-button>
                <el-button @click="resetChecked">清空</el-button>
            </div>
            <div class="toAllocateBox">
                <h3>发布资源</h3>
                <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm toAllocateBoxForm">
                    <el-form-item label="父资源" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="资源名" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="资源类型" prop="region">
                        <el-select v-model="ruleForm.region" placeholder="请选择活动区域">
                            <el-option label="目录" value="shanghai"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="资源KEY" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="URL" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="备注" prop="desc">
                        <el-input type="textarea" ></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary">发布</el-button>
                    </el-form-item>
                </el-form>
            </div>

            <div class="toAllocateBox">
                <h3>修改资源</h3>
                <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm toAllocateBoxForm">
                    <el-form-item label="资源名" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="资源KEY" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="URL" prop="name">
                        <el-input></el-input>
                    </el-form-item>

                    <el-form-item label="资源类型" prop="region">
                        <el-select v-model="ruleForm.region" placeholder="请选择活动区域">
                            <el-option label="目录" value="shanghai"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="资源状态" prop="region">
                        <el-select v-model="ruleForm.region2" placeholder="请选择活动区域">
                            <el-option label="上线" value="shanghai"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="备注" prop="desc">
                        <el-input type="textarea" ></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary">修改</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "rightsManagement",
        data() {
            return {
                ruleForm: {
                    name: '',
                    region: '目录',
                    region2: '上线',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: ''
                },
                data3: [{
                    id: 1,
                    label: '借款管理平台',
                    children: [{
                        id: 21,
                        label: '借款管理',
                        children: [{
                            id: 31,
                            label: '贷款申请',
                            children: [
                                {
                                    id: 3141,
                                    label: '新增'
                                },
                                {
                                    id: 3142,
                                    label: '修改'
                                },
                                {
                                    id: 3143,
                                    label: '删除'
                                }]
                        },
                        {
                            id: 32,
                            label: '面签列表',
                            children: [{
                                id: 3241,
                                label: '面签批复'
                            },
                            {
                                id: 3242,
                                label: '修改'
                            }]
                        },
                        {
                            id: 33,
                            label: '家访列表',
                            children: [{
                                id: 3341,
                                label: '家访确认'
                            }]
                        },
                        {
                            id: 34,
                            label: '财务审核',
                            children: [{
                                id: 3441,
                                label: '财务核算'
                            },
                            {
                                id: 3442,
                                label: '修改'
                            }]
                        },
                        {
                            id: 35,
                            label: '风控审核',
                            children: [{
                                id: 3541,
                                label: '确认'
                            }]
                        },
                        {
                            id: 36,
                            label: '协议上传',
                            children: [{
                                id: 3641,
                                label: '上传协议'
                            },
                            {
                                id: 3642,
                                label: '查看协议'
                            }]
                        },
                        {
                            id: 37,
                            label: '资产管理',
                            children: [{
                                id: 3741,
                                label: '匹配/发标'
                            },
                            {
                                id: 3742,
                                label: '发标审核'
                            },
                            {
                                id: 3743,
                                label: '满标审核'
                            },
                            {
                                id: 3744,
                                label: '暂停/截标'
                            },
                            {
                                id: 3745,
                                label: '确认放款'
                            },
                            {
                                id: 3746,
                                label: '还款/续借'
                            },
                            {
                                id: 3747,
                                label: '查看'
                            }]
                        }]
                    },
                    {
                        id: 12,
                        label: '会员管理',
                        children: [{
                            id: 121,
                            label: '会员列表',
                            children: [{
                                id: 1211,
                                label: '查看'
                            }]
                        }]
                    },
                    {
                        id: 13,
                        label: '标的管理',
                        children: [{
                            id: 131,
                            label: '审核'
                        },
                        {
                            id: 132,
                            label: '编辑'
                        },
                        {
                            id: 133,
                            label: '暂定/截标'
                        },
                        {
                            id: 134,
                            label: '查看'
                        }]
                    }]
                }],
                defaultProps: {
                    children: 'children',
                    label: 'label'
                },
                tableData: [
                    {
                        id: 1,
                        state: "待面签",
                        username: "UserName-1",
                        borrower: "张三",
                        idcard: "451012199911362576",
                        telephone: "130 6890 5634",
                        models: "奥迪A4",
                        explain: "2009年车",
                        quota: "10,000.00",
                        deadline: 6,
                        create: "2016.09.08 21:08:06",
                        clerk: "业务经理001"
                    }
                ],
                pageNum: 1
            };
        },
        methods: {
            getCheckedNodes() {
                console.log(this.$refs.tree.getCheckedNodes());
            },
            getCheckedKeys() {
                console.log(this.$refs.tree.getCheckedKeys());
            },
            setCheckedNodes() {
                this.$refs.tree.setCheckedNodes([{
                    id: 35,
                    label: '二级 2-1'
                }, {
                    id: 36,
                    label: '三级 1-1-1'
                }]);
            },
            setCheckedKeys() {
                this.$refs.tree.setCheckedKeys([3]);
            },
            resetChecked() {
                this.$refs.tree.setCheckedKeys([]);
            }
        }
    };
</script>

<style lang="scss">
    #rightsManagement{
        padding: 20px;
        overflow: hidden;
        .salesman-tree{
            position: relative;
            float: left;
            width: 300px;
            min-height: 80px;
            border: 1px solid #eee;
            overflow: hidden;
            .el-tree{
                border: none!important;
            }
            .salesman-tree-save{
                position: absolute;
                top: 20px;
                right: 20px;
            }
        }
        .salesman-content{
            margin-left: 320px;
            overflow: hidden;
            .toAllocateBox{
                width: 700px;
                padding: 0px;
                border: 1px solid #eee;
                margin-bottom: 50px;
                h3{
                    border-bottom: 1px solid #eee;
                    padding: 15px;
                }
                .toAllocateBoxForm{
                    margin: 20px;
                }
            }

        }
    }
</style>
